package model;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * Class, representing the player in the game with name, sign and current score
 * 
 * @author random.org
 * 
 */

public class Player {

        private static final String[] PLAYER_SIGNS = { "X", "O", "^", "*" };

        private String name;
        private String sign;
        static int previousChoise = Integer.MIN_VALUE;
        private int currentScore;

        public Player(String name, String sign) {
                setName(name);
                setSign(sign);
                currentScore=0;
        }

        /**
         * Asking the player to choose a sign for the current game.
         */
        private void setSign(String sign) {
        	if(sign!=null && sign.length()>0)
               this.sign = sign;
        }

        /**
         * Setting a name to the current player.
         * 
         * @param name
         *            - name of the player.
         */
        private void setName(String name) {
                if (name != null && !name.equals(""))
                        this.name = name;
        }

        /**
         * Asking the player to enter his name.
         */
//        private void chooseName() {
//                Scanner sc = new Scanner(System.in);
//                String name = " ";
//                do {
//                        System.out.println("Please enter your name: ");
//                        name = sc.nextLine();
//                } while (name == null || name.length() == 0);
//                setName(name);
//        }

        /**
         * Setting a sign to the current player.
         * 
         * @param choice
         *            - choice number.
         */
//        private void setSign(int choice) {
//                if (choice > 0 && choice <= 4 && choice != previousChoise) {
//                        switch (choice) {
//                        case 1: {
//                                sign = PLAYER_SIGNS[0];
//                                previousChoise = choice;
//                                break;
//                        }
//                        case 2: {
//                                sign = PLAYER_SIGNS[1];
//                                previousChoise = choice;
//                                break;
//                        }
//                        case 3: {
//                                sign = PLAYER_SIGNS[2];
//                                previousChoise = choice;
//                                break;
//                        }
//                        case 4: {
//                                sign = PLAYER_SIGNS[3];
//                                previousChoise = choice;
//                        }
//                        }
//                } else {
//                        if (choice == previousChoise) {
//                                System.out
//                                                .println("\nNumber "
//                                                                + Player.previousChoise
//                                                                + " is already taken! Please choose one of the others !");
//                        } else {
//                                System.out.println("\nPlease, enter a valid digit!");
//                        }
//                        chooseSign();
//                }
//        }

        /**
         * Increments the current score of the player
         */
        public void increaseScore(int score) {
                currentScore += score;
        }

        /**
         * 
         * @return the player name.
         */
        public String getName() {
                return this.name;
        }

        /**
         * 
         * @return the player sign.
         */
        public String getSign() {
                return sign;
        }

        /**
         * 
         * @return the player score.
         */
        public int getCurrentScore() {
                return currentScore;
        }

}